﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using RVEAd.Models;

namespace RVEAd.Helpers
{
    public static class FileSystem
    {
        public static List<Models.SpotFile> GetFolderFiles(string folder, string searchToken)
        {
            if (Directory.Exists(folder))
            {

                searchToken = searchToken.ToLower();

                return Directory
                    .GetFiles(folder, "*", SearchOption.AllDirectories)
                    .Where(f => ((string.IsNullOrEmpty(searchToken)) || (f.ToLower().Contains(searchToken))))
                    .Select(f => new SpotFile
                                     {
                                         Description = (new FileInfo(f)).Name
                                     })
                    .ToList();
            }

            return null;
        }
    }
}
